package com.web44.spring.service.proxy;

import com.web44.spring.service.Calculator;

/**
 * @Title: CalculatorStaticProxy
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2024/1/9 14:05
 */
public class CalculatorStaticProxy implements Calculator {

    private Calculator calculator;

    public CalculatorStaticProxy(Calculator calculator) {
        this.calculator = calculator;
    }

    @Override
    public int add(int i, int j) {
        // 前增强
        System.out.println("[日志] add 方法开始了，参数是：" + i + "," + j);
        int result = calculator.add(i,j);
        // 后增强
        System.out.println("[日志] add 方法结束了，结果是：" + result);
        return result;
    }

    @Override
    public String fun(int i, int j) {
        return null;
    }

    @Override
    public int add(int i, int j, int k) {
        return 0;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("[日志] sub 方法开始了，参数是：" + i + "," + j);
        int result = calculator.sub(i,j);
        System.out.println("[日志] sub 方法结束了，结果是：" + result);
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("[日志] mul 方法开始了，参数是：" + i + "," + j);
        int result = calculator.mul(i,j);
        System.out.println("[日志] mul 方法结束了，结果是：" + result);
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("[日志] div 方法开始了，参数是：" + i + "," + j);
        int result = calculator.div(i,j);
        System.out.println("[日志] div 方法结束了，结果是：" + result);
        return result;
    }
}
